(function(){"use strict";BX.namespace("BX.Landing.TileGrid");BX.Landing.TileGrid=function(i){this.transferPopup="";if(typeof i==="object"){this.siteId=i.siteId;this.siteType=i.siteType;this.wrapper=i.wrapper;this.inner=i.inner;this.tiles=i.tiles;this.minTileWidth=0;this.maxTileWidth=0;this.tileRowLength=0;if(i.sizeSettings){this.minTileWidth=i.sizeSettings.minWidth;this.maxTileWidth=i.sizeSettings.maxWidth}else if(i.tileRowLength){this.tileRowLength=i.tileRowLength}else{this.minTileWidth=250;this.maxTileWidth=350}this.tileRatio=i.tileRatio||1.48;this.maxTileHeight=this.maxTileWidth/this.tileRatio;this.setTileWidth();BX.bind(window,"resize",this.setTileWidth.bind(this));requestAnimationFrame(function(){this.wrapper.classList.add("landing-ui-show")}.bind(this))}};BX.Landing.TileGrid.prototype={setTileWidth:function(){var i=this.getTileCalculating();var e=i.width;var t=i.height;if(this.minTileWidth){e=e<=this.maxTileWidth?i.width:this.maxTileWidth;t=t<=this.maxTileHeight?i.height:this.maxTileHeight}requestAnimationFrame(function(){for(var s=0;s<this.tiles.length;s++){this.tiles[s].style.width=e+"px";this.tiles[s].style.height=t+"px";this.tiles[s].style.marginLeft=i.margin+"px";this.tiles[s].style.marginTop=i.margin+"px"}this.inner.style.marginLeft=i.margin*-1+"px";this.inner.style.marginTop=i.margin*-1+7+"px"}.bind(this))},getTileCalculating:function(){var i=this.wrapper.clientWidth-12;var e=i/100*6;var t=0,s=0;if(this.tileRowLength){s=this.tileRowLength;t=(i-e)/this.tileRowLength}else{t=this.minTileWidth;s=(i-e)/t;if(s>this.tiles.length){t=(i-e)/this.tiles.length;t=t>this.maxTileWidth?this.maxTileWidth:t}else if(s-Math.floor(s)>0){s=Math.floor(s);t=(i-e)/s}}return{width:t,margin:e/(s-1),height:t/this.tileRatio}},action:function(i,e,t,s){var n=BX.create("div",{attrs:{className:"landing-filter-loading-container"}});document.body.appendChild(n);var r=new BX.Loader({size:130,color:"#bfc3c8"});r.show(n);BX.ajax({url:BX.util.add_url_param(window.location.href,{action:i}),method:"POST",data:{data:e,sessid:BX.message("bitrix_sessid"),actionType:"rest",componentName:typeof s!=="undefined"?s:null},dataType:"json",onsuccess:function(i){r.hide();n.classList.add("landing-filter-loading-hide");if(typeof i.type!=="undefined"&&typeof i.result!=="undefined"){if(i.type==="error"){var e=BX.Landing.UI.Tool.ActionDialog.getInstance();if(i.error_type==="payment"&&(i.result[0].error==="PUBLIC_SITE_REACHED"||i.result[0].error==="TOTAL_SITE_REACHED"||i.result[0].error==="PUBLIC_PAGE_REACHED"||i.result[0].error==="PUBLIC_SITE_REACHED_FREE")){if(i.result[0].error==="PUBLIC_PAGE_REACHED"){top.BX.UI.InfoHelper.show("limit_sites_number_page")}else if(i.result[0].error==="PUBLIC_SITE_REACHED_FREE"){top.BX.UI.InfoHelper.show("limit_sites_free")}else{if(this.siteType==="STORE"){top.BX.UI.InfoHelper.show("limit_shop_number")}else if(this.siteType==="KNOWLEDGE"){top.BX.UI.InfoHelper.show("limit_knowledge_base_number_page")}else{top.BX.UI.InfoHelper.show("limit_sites_number")}}}else if(i.result[0].error==="FREE_DOMAIN_IS_NOT_ALLOWED"){top.BX.UI.InfoHelper.show("limit_free_domen")}else if(i.result[0].error==="EMAIL_NOT_CONFIRMED"){top.BX.UI.InfoHelper.show("limit_sites_confirm_email")}else if(i.result[0].error==="PHONE_NOT_CONFIRMED"&&BX.Bitrix24&&BX.Bitrix24.PhoneVerify){BX.Bitrix24.PhoneVerify.getInstance().setEntityType("landing_site").setEntityId(this.siteId).startVerify({mandatory:false})}else if(typeof BX.Landing.PaymentAlertShow!=="undefined"&&i.error_type==="payment"){BX.Landing.PaymentAlertShow({message:i.result[0].error_description})}else{e.show({content:i.result[0].error_description,confirm:"OK",type:"alert"})}}else{if(typeof t==="function"){t(i)}else{if(top.window!==window){window.location.reload()}else{BX.onCustomEvent("BX.Landing.Filter:apply")}}}}}.bind(this)})}}})();
//# sourceMappingURL=script.map.js